﻿CREATE TABLE [dbo].[ProductPictures]
(
	[Id] INT NOT NULL PRIMARY KEY IDENTITY, 
    [GUID] NVARCHAR(36) NOT NULL, 
    [Width] INT NULL, 
    [Height] INT NULL, 
    [Size] NUMERIC NULL, 
    [ProductId] INT NULL, 
    [AddTime] DATETIME NOT NULL DEFAULT GETDATE(), 
    [IsCover] BIT NOT NULL DEFAULT 0, 
    CONSTRAINT [FK_Pictures_Product] FOREIGN KEY ([ProductId]) REFERENCES [Product]([Id])
)

GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'图片ID',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'ProductPictures',
    @level2type = N'COLUMN',
    @level2name = N'Id'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'图片唯一标识',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'ProductPictures',
    @level2type = N'COLUMN',
    @level2name = N'GUID'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'图片宽度',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'ProductPictures',
    @level2type = N'COLUMN',
    @level2name = N'Width'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'图片高度',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'ProductPictures',
    @level2type = N'COLUMN',
    @level2name = N'Height'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'图片文件大小',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'ProductPictures',
    @level2type = N'COLUMN',
    @level2name = N'Size'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'图片所属产品',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'ProductPictures',
    @level2type = N'COLUMN',
    @level2name = N'ProductId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'添加日期',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'ProductPictures',
    @level2type = N'COLUMN',
    @level2name = N'AddTime'
GO

EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'是否是封面图片',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'ProductPictures',
    @level2type = N'COLUMN',
    @level2name = N'IsCover'